package com.huqing.icu.rentuser.dao;

import com.huqing.icu.rentuser.dto.UserNumPanelQueryDto;
import com.huqing.icu.rentuser.mapper.UserNumPanelMapper;
import com.huqing.icu.rentuser.model.UserNumPanel;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;
import java.util.List;

/**
 * @Description 活跃用户数量表的dao
 * @Author huqing
 * @Date 2025/9/4 9:59
 **/
@Repository
public class UserNumPanelDao {

    @Resource
    private UserNumPanelMapper userNumPanelMapper;

    public void insert(UserNumPanel userNumPanel) {
        userNumPanelMapper.insert(userNumPanel);
    }

    public Integer incrAddUserNumAndUserNum(Long id) {
        return userNumPanelMapper.incrAddUserNumAndUserNum(id);
    }

    public Integer incrActiveUserNum(Long id) {
        return userNumPanelMapper.incrActiveUserNum(id);
    }

    public void updateById(Long id, Integer userNum) {
        UserNumPanel userNumPanel = new UserNumPanel();
        userNumPanel.setId(id);
        userNumPanel.setActiveUserNum(userNum);
        userNumPanel.setModifyTime(new Timestamp(System.currentTimeMillis()));
        userNumPanelMapper.updateById(userNumPanel);
    }

    public Integer getNumByCondition(UserNumPanelQueryDto queryDto) {
        return userNumPanelMapper.getNumByCondition(queryDto);
    }

    public List<UserNumPanel> selectByCondition(UserNumPanelQueryDto queryDto) {
        return userNumPanelMapper.selectByCondition(queryDto);
    }

    public List<UserNumPanel> selectDateByDate(List<String> dateList) {
        return userNumPanelMapper.selectDateByDate(dateList);
    }
}
